module.exports = {
    async del({roomDeatilID,roomMsg,ctx}){
        let nextOne = [];
          await ctx.model.RoomDetail.destroy({where:{id:roomDeatilID}})
          nextOne = await ctx.model.RoomDetail.findAll({where:{room_id:roomMsg.room_id}});
          if(roomMsg.is_owners==1){        
            if(nextOne.length>0){
              await ctx.model.RoomDetail.update({is_owners:1},{where:{id:nextOne[0].id}});
              await ctx.model.Room.update({owners_id:nextOne[0].user_id,owners:nextOne[0].user_name},{where:{id:nextOne[0].room_id}});
            }else{
              await ctx.model.Room.destroy({where:{id:roomMsg.room_id}});
            }
          }
          await ctx.model.Room.update({person_num:nextOne.length},{where:{id:roomMsg.room_id}})
          ctx.body = {code:1,msg:''}
          return ctx.body;
      }
}